﻿<template>
    <!-- 202311 -->
  <a-modal
    :title="title"
    width="600px"
    :visible="visible"
    dialogClass="zero-modal"
    @cancel="handleCancel">
    <a-spin :spinning="confirmLoading">
      <div class="bind-entrance-edit-modal-content">
        <a-form :form="form" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-form-item label="物料编码">
            <a-input placeholder="请输入物料编码" allow-clear v-decorator="['materialNo',{rules:[{required:true,message:'物料编码不可为空！'}]}]" />
          </a-form-item>
          <a-form-item label="MaterialName">
            <a-input placeholder="请输入" allow-clear v-decorator="['MaterialName',{rules:[{required:true,message:'不可为空！'}]}]" />
          </a-form-item>
          <a-form-item label="MaterialDensity">
            <a-input placeholder="请输入MaterialDensity" allow-clear v-decorator="['MaterialDensity',{rules:[{required:true,message:'MaterialDensity不可为空！'}]}]" />
          </a-form-item>
          <a-form-item label="MaterialBatch">
            <a-input placeholder="请输入批次" allow-clear v-decorator="['MaterialBatch',{rules:[{required:true,message:'不可为空！'}]}]" />
          </a-form-item>
          
          <!-- <a-row :gutter="16">
            <a-col :span="8">
              <a-form-item label="长">
                <a-input-number placeholder="请输入长" allow-clear style="width: 100%" v-decorator="['long',{rules:[{required:true,message:'长不可为空！'},{ validator: numberValidate }]}]" :min="0" />
              </a-form-item>
            </a-col>
            <a-col :span="8">
              <a-form-item label="宽">
                <a-input-number placeholder="请输入宽" allow-clear style="width: 100%" v-decorator="['wide',{rules:[{required:true,message:'宽不可为空！'},{ validator: numberValidate }]}]" :min="0" />
              </a-form-item>
            </a-col>
            <a-col :span="8">
              <a-form-item label="高">
                <a-input-number placeholder="请输入高" allow-clear style="width: 100%" v-decorator="['high',{rules:[{required:true,message:'高不可为空！'},{ validator: numberValidate }]}]" :min="0" />
              </a-form-item>
            </a-col>
          </a-row> -->
          
        </a-form>
      </div>
    </a-spin>
    
    <template slot="footer">
      <a-button key="back" @click="handleCancel">取消</a-button>
      <a-button key="submit" type="primary" :loading="confirmLoading" @click="handleSubmit">确认</a-button>
    </template>
  </a-modal>
</template>
 
<script>
  export default {
    emits:['callback'],
    data () {
      return {
        labelCol: {
          span:24
        },
        wrapperCol: {
          span:24
        },
        visible: false,
        confirmLoading: false,
        title:'新增主板物料',
        form: this.$form.createForm(this)
      }
    },
    methods: {
      // 初始化方法
      init () {
        let _initForm = {materialNo:''}
        this.visible = true
        this.$nextTick(()=>{
          this.form.setFieldsValue(_initForm)
        })
      },
      numberValidate(rule, value, callback){
        if (value<=0){
          callback('必须大于0');
        } else {
          callback();
        }
      },
      handleSubmit () {
        this.form.validateFields((errors, values) => {
          if (!errors) {
            this.handleCancel()
            this.$emit('callback',values)
          }
        })
      },
      handleCancel () {
        this.visible = false
      }
    }
  }
</script>
<style lang="less" scoped>
.bind-entrance-edit-modal-content{
  padding: 20px 16px 0 16px;
}
</style>